﻿
@{
    ViewBag.Title = "拼柜详情";
    Layout = "~/Views/Shared/_LayoutPage.cshtml";
}
@model IOA.MES.DataAccess.VModel.VCabinet


<div id="page"></div>

<script type="text/template" id="tplPage">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                {{lang.Field.CabinetNo}}：@Model.CabinetNo，{{lang.Field.Operator}}：@Model.CNCreateBy，{{lang.Field.CabinetTime}}：@Model.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
                <button id="btnUnCabinet" class="layui-btn layuiadmin-btn-list" type="button">
                    <i class="layui-icon layui-icon-cols layuiadmin-button-btn"></i>{{lang.Field.UnCabinet}}
                </button>
            </div>
            <div class="layui-card-body">
                <table id="table" lay-filter="table"></table>
            </div>
        </div>
    </div>
</script>

@section Scripts{
    <script>
        var vm = new Vue({
            el: "#page",
            template: "#tplPage",
            data: {
                lang: JSON.parse(lang).package,
                packs: @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.Packs))
            }
        });

        setTimeout(function () {
            initLayui();
        }, 50);

        function initLayui() {
            layui.use(['table', 'layer', 'laydate', 'form'], function () {
                var table = layui.table;

                var options = {
                    elem: '#table'
                    , data: vm.$data.packs
                    , limit: 1000
                    , cols: [[
                        { title: '序号', type: "numbers", width: 100 }
                        , { field: 'PackNo', title: '打包编号', minWidth: 200 }
                        , { field: 'QLevel', title: '等级' }
                        , { field: 'ComponentColor', title: '颜色' }
                        , { field: 'IVPowerLevel', title: '功率' }
                        , { field: 'IVCurrentLevel', title: '档位' }
                        , { field: 'NameplateModel', title: '铭牌型号' }
                        , { field: 'Location', title: '库位号' }
                    ]]
                };
                table.render(options);

                $(document).on("click", "#btnUnCabinet", function () {
                    layer.confirm('确定要解柜吗？', { icon: 3, title: '提示' }, function (index) {
                        var loadId = layer.load();
                        $.ajax({
                            url: "/Warehouse/UnCabinet",
                            data: {
                                cabinetNo: '@Model.CabinetNo'
                            },
                            complete: function () {
                                layer.close(loadId);
                            },
                            success: function (res) {
                                if (res.ErrCode != 200) {
                                    layer.msg(res.ErrMsg, { icon: 5 });
                                    return;
                                }
                                layer.msg("解柜成功！", { icon: 6, time: 1500 });

                            }
                        });
                        layer.close(index);
                    });
                });
            });
        }
    </script>
}
